import { createRouter, createWebHistory } from 'vue-router'
import type {RouteRecordRaw} from 'vue-router'
export const MenuRoutes:RouteRecordRaw[]=[
  {
    path:'/',
    component:()=>import("@/views/index/index.vue")
  },
  {
    path:"/index",
    meta:{
      title:"首页"
    },
    component:()=>import("@/views/index/index.vue")
  },
   
  {
    path:"/index/map",
    meta:{
      title:"地图"
    },
    component:()=>import("@/views/map/index.vue")
  },
{
    path:"/index/map2",
    meta:{
      title:"地图2"
    },
    component:()=>import("@/views/map2/index.vue")
  },
  {
    path:"/index/vip",
    meta:{
      title:"会员"
    },
    component:()=>import("@/views/vip/index.vue")
  },
  {
    path:"/index/healthy",
    meta:{
      title:"健康"
    },
    component:()=>import("@/views/healthy/index.vue")
  },
   {
    path:"/index/Consultation",
    meta:{
      title:"问诊"
    },
    component:()=>import("@/views/Consultation/index.vue")
  },
  {
    path:"/index/my",
    meta:{
      title:"我的"
    },
    component:()=>import("@/views/my/index.vue")
  },
  {
    path:"/index/Quickconsultation",
    meta:{
      title:"快速问诊"
    },
    component:()=>import("@/views/Quickconsultation/index.vue")
  },
  {
    path:"/index/Expertconsultation",
    meta:{
      title:"专家问诊"
    },
    component:()=>import("@/views/Expert consultation/index.vue")
  },
  {
    path:"/index/Goregister",
    meta:{
      title:"去挂号"
    },
    component:()=>import("@/views/Go register/index.vue")
  },
  {
    path:"/index/ybdw",
    meta:{
      title:"一病多问"
    },
    component:()=>import("@/views/yibingduowen/index.vue")
  },
  {
    path:"/index/jiankangshangcheng",
    meta:{
      title:"健康商城"
    },
    component:()=>import("@/views/jiankangshop/index.vue")
  },
  {
    path:"/index/tuominwuyou",
    meta:{
      title:"脱敏无忧"
    },
    component:()=>import("@/views/tuominwuyou/index.vue")
  },
  {
    path:"/index/wenzhengouyao",
    meta:{
      title:"问诊购药"
    },
    component:()=>import("@/views/wenzhengoyao/index.vue")
  },
  {
    path:"/index/jiankanghaowu",
    meta:{
      title:"健康好物"
    },
    component:()=>import("@/views/jiankanghaowu/index.vue")
  },
  {
    path:"/index/healthyvip",
    meta:{
      title:"健康会员"
    },
    component:()=>import("@/views/healthyvip/index.vue")

  },
  {
    path:"/index/zhuanbingzhuanke",
    meta:{
      title:"专病专科"
    },
    component:()=>import("@/views/zhuanbingzhuanke/index.vue")
    },
    {
      path:"/index/yaoshitongyuan",
      meta:{
        title:"药食同源"
      },
      component:()=>import("@/views/yaoshitongyuan/index.vue")
    },
    {
      path:"/index/sanjiatijian",
      meta:{
        title:"三甲体检"
      },
      component:()=>import("@/views/sanjiatiyan/index.vue")
    },
    {
      path:"/index/zhongyitiaoli",
      meta:{
        title:"中医调理"
      },
      component:()=>import("@/views/zhongyitiaoli/index.vue")
    },
    {
      path:"/index/jiankangzhushou",
      meta:{
        title:"健康助手"
      },
      component:()=>import("@/views/jiankangzhushou/index.vue")
    },
    {
      path:"/index/newuser",
      meta:{
        title:"新用户"
      },
      component:()=>import("@/views/newuser/index.vue")
    },
    {
      path:"/index/pifubing",
      meta:{
        title:"皮肤病"
      },
      component:()=>import("@/views/pifubing/index.vue")
    },
    {
      path:"/index/erke",
      meta:{
        title:"儿科"
      },
      component:()=>import("@/views/erke/index.vue")
    },
    {
      path:"/index/fuke",
      meta:{
        title:"妇科"
      },
      component:()=>import("@/views/fuke/index.vue")
    },
    {
      path:"/index/jianzhong",
      meta:{
        title:"减重专区"
      },
      component:()=>import("@/views/jianzhong/index.vue")
    },
    {
      path:"/index/weichang",
      meta:{
        title:"胃肠专区"
      },
      component:()=>import("@/views/weichang/index.vue")
    },
    {
      path:"/index/AI",
      meta:{
        title:"AI智能"
      },
      component:()=>import('@/views/Ai/index.vue')
    },
    {
      path:"/index/xinli",
      meta:{
        title:"心理专区"
      },
      component:()=>import("@/views/xinli/index.vue")
    },
     {
    path:'/shoucang',
    meta:{
      title:"我的收藏"
    },
    component:()=>import('../views/shoucang/index.vue')

  },
    {
    path:'/doctor',
    meta:{
      title:"我的医生"
    },
    component:()=>import('../views/doctor/index.vue')

  },
      {
    path:'/jiankang',
    meta:{
      title:"健康商城"
    },
    component:()=>import('../views/jiankang/index.vue')

  },
      {
    path:'/gongneng',
    meta:{
      title:"功能介绍"
    },
    component:()=>import('../views/gongneng/index.vue')

  },
     {
    path:'/kefu',
    meta:{
      title:"客服中心"
    },
    component:()=>import('../views/kefu/index.vue')

  },
     {
    path:'/fapiao',
    meta:{
      title:"我的发票"
    },
    component:()=>import('../views/fapiao/index.vue')

  },
     {
    path:'/zhangbei',
    meta:{
      title:"长辈模式"
    },
    component:()=>import('../views/zhangbei/index.vue')

  },
     {
    path:'/suifang',
    meta:{
      title:"随访计划"
    },
    component:()=>import('../views/suifang/index.vue')

  },
     {
    path:'/huaxiang',
    meta:{
      title:"健康画像"
    },
    component:()=>import('../views/huaxiang/index.vue')

  },
     {
    path:'/shangwu',
    meta:{
      title:"商务合作"
    },
    component:()=>import('../views/shangwu/index.vue')

  },
     {
    path:'/shequn',
    meta:{
      title:"医患社群"
    },
    component:()=>import('../views/shequn/index.vue')

  },
     {
    path:'/zhuanqu',
    meta:{
      title:"福利专区"
    },
    component:()=>import('../views/zhuanqu/index.vue')

  },
   {
    path:'/edit',
    meta:{
      title:"退出"
    },
    component:()=>import('../views/edit/index.vue')

  },
     {
    path:'/pinglun',
    meta:{
      title:"评论页面"
    },
    component:()=>import('../views/pinglun/index.vue')

  },
   {
    path:'/dizhi',
    meta:{
      title:"地址管理"
    },
    component:()=>import('../views/dizhi/index.vue')

  },
  {
    path:'/dizhi1',
    meta:{
      title:"地址添加"
    },
    component:()=>import('../views/dizhi1/index.vue')

  },
  {
    path:'/zhanghao',
    meta:{
      title:"账号设置"
    },
    component:()=>import('../views/zhanghao/index.vue')

  },
    {
    path:'/jiating',
    meta:{
      title:"家庭联系人"
    },
    component:()=>import('../views/jiating/index.vue')

  },
    {
    path:'/jiating1',
    meta:{
      title:"家庭"
    },
    component:()=>import('../views/jiating1/index.vue')

  },
     {
    path:'/ditu',
    meta:{
      title:"地图"
    },
    component:()=>import('../views/ditu/index.vue')

  },
  
]
const Routes:RouteRecordRaw[]=[
  {
    path:"/",
    meta:{
      title:"布局"
    },
    component:()=>import("@/views/layout/index.vue"),
    children:MenuRoutes
  },
  {
    path:"/login",
    meta:{
      title:"登录"
    },
    component:()=>import("@/views/login/index.vue")
  },
  {
    path:"/cart",
    meta:{
      title:"购物车"
    },
    component:()=>import("@/views/cart/index.vue")
  },
   {
    path:"/order",
    meta:{
      title:"订单"
    },
    component:()=>import("@/views/order/index.vue")
  },
  {
    path:"/detail/:id",
    meta:{
      title:"详情",
      KeepAlive:false
    },
    component:()=>import("@/views/detail/index.vue")
  },
    {
    path:"/todetail/:id",
    meta:{
      title:"好物详情",
      KeepAlive:false
    },
    component:()=>import("@/views/todetail/index.vue")
  },
  {
    path:"/search",
    meta:{
      title:"搜索"
    },
    component:()=>import("@/views/search/index.vue")
  }
]
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: Routes
})
router.beforeEach((to,from,next)=>{
    if(to.path==='/login'){
      next()
    }else{
      const token=localStorage.getItem('token')
      if(!token){
        alert('请先登录')
        next('/login')
      }else{
        next()
      }
    }
})


export default router
